package com.test.dao;

import com.test.entity.AuthUser;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    @Select("select * from users where name=#{username}")
    AuthUser getUserByLogin(@Param("username") String name);

    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into users(name,role,password) values(#{authUser.username},#{authUser.role},#{authUser.password})")
    int registerUser(@Param("authUser") AuthUser authUser);

    @Insert("insert into student(uid,name,grade,sex) values(#{uid},#{name},#{grade},#{sex})")
    int addStudentInfo(@Param("uid") int uid, @Param("name") String name, @Param("grade") String grade, @Param("sex") String sex);

    @Select("select sid from student where uid=#{uid}")
    Integer getSidByUserId(int uid);
}
